package com.wing.bill.controller.admin;

import com.wing.bill.service.MaterielReportService;
import com.wing.common.utils.JsonResult;
import com.wing.web.utils.JwtUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Validated
@Api(value = "Admin-刀具柜库存报表", tags = "#/bill/inventoryReport")
@RestController("inventoryReportController")
@RequestMapping("bill/admin/inventoryReport")
@RequiredArgsConstructor
public class InventoryReportController {

    private final MaterielReportService materielReportService;

    @ApiOperation(value = "新报表顶部图", notes = "搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "selectParam", value="下拉选项参数(系列-spu 编号-sku 品牌-brand 类型-type 分类-category)", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "param", value = "开关参数(数量-qua 金额-money)",  dataType = "String", paramType = "query")
    })
    @GetMapping("/list")
    public JsonResult listNew(
            @RequestParam("endTime")String endTime
            ,@RequestParam("selectParam")String selectParam
            ,@RequestParam("param")String param
            ,@RequestParam("mainCabCode") String mainCabCode
    ){
        return materielReportService.listNew(endTime,selectParam,param,mainCabCode, JwtUtils.getEnterpriseCode());
    }

    @ApiOperation(value = "售刀柜顶部格子", notes = "搜索")
    @GetMapping("/topCellBySell")
    public JsonResult topCellBySell(
            @RequestParam("click")String click,
            @RequestParam("endTime")String endTime,
            @RequestParam("mainCabCode")String mainCabCode
    ){
        return materielReportService.topCellBySell(endTime,Integer.valueOf(click),mainCabCode,JwtUtils.getEnterpriseCode());
    }

    @ApiOperation(value = "售刀柜物料在库排名(按物料)", notes = "搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "selectParam", value="下拉选项参数(系列-spu 编号-sku 品牌-brand 类型-type 分类-category)", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "param", value = "开关参数(数量-qua 金额-money)",  dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "tab", value = "tab参数(总览tab-tab0 物料tab-tab1)",  dataType = "String", paramType = "query")
    })
    @GetMapping("/querySellSkuRanking")
    public JsonResult querySellSkuRanking(
            @RequestParam("endTime")String endTime
            ,@RequestParam("selectParam")String selectParam
            ,@RequestParam("param")String param
            ,@RequestParam("mainCabCode") String mainCabCode
            ,String tab
    ){
        return materielReportService.querySellSkuOrCabRanking(endTime,selectParam,param,mainCabCode,JwtUtils.getEnterpriseCode(),"sku",tab);
    }

    @ApiOperation(value = "售刀柜物料在库排名(按柜子)", notes = "搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "selectParam", value="下拉选项参数(主柜-main 副柜-desk 货道-space)", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "param", value = "开关参数(数量-qua 金额-money)",  dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "tab", value = "tab参数(总览tab-tab0 柜子tab-tab1)",  dataType = "String", paramType = "query")
    })
    @GetMapping("/querySellCabRanking")
    public JsonResult querySellCabRanking(
            @RequestParam("endTime")String endTime
            ,@RequestParam("selectParam")String selectParam
            ,@RequestParam("param")String param
            ,@RequestParam("mainCabCode") String mainCabCode
            ,String tab
    ){
        return materielReportService.querySellSkuOrCabRanking(endTime,selectParam,param,mainCabCode,JwtUtils.getEnterpriseCode(),"cab",tab);
    }


    @ApiOperation(value = "存刀柜顶部格子", notes = "搜索")
    @GetMapping("/topCellByStore")
    public JsonResult topCellByStore(
            @RequestParam("click")String click,
            @RequestParam("endTime")String endTime,
            @RequestParam("mainCabCode")String mainCabCode
    ){
        return materielReportService.topCellByStore(endTime,Integer.valueOf(click),mainCabCode,JwtUtils.getEnterpriseCode());
    }

    @ApiOperation(value = "存刀柜物料在库排名(按物料)", notes = "搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "selectParam", value="下拉选项参数(系列-spu 编号-sku 品牌-brand 类型-type 分类-category)", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "param", value = "开关参数(数量-qua 金额-money)",  dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "tab", value = "tab参数(总览tab-tab0 物料tab-tab1)",  dataType = "String", paramType = "query")
    })
    @GetMapping("/queryStoreSkuRanking")
    public JsonResult queryStoreSkuRanking(
            @RequestParam("endTime")String endTime
            ,@RequestParam("selectParam")String selectParam
            ,@RequestParam("param")String param
            ,@RequestParam("mainCabCode") String mainCabCode
            ,String tab
    ){
        return materielReportService.queryStoreSkuOrCabRanking(endTime,selectParam,param,mainCabCode,JwtUtils.getEnterpriseCode(),"sku",tab);
    }

    @ApiOperation(value = "存刀柜物料在库排名(按柜子)", notes = "搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "selectParam", value="下拉选项参数(主柜-main 副柜-desk 货道-space)", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "param", value = "开关参数(数量-qua 金额-money)",  dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "tab", value = "tab参数(总览tab-tab0 柜子tab-tab1)",  dataType = "String", paramType = "query")
    })
    @GetMapping("/queryStoreCabRanking")
    public JsonResult queryStoreCabRanking(
            @RequestParam("endTime")String endTime
            ,@RequestParam("selectParam")String selectParam
            ,@RequestParam("param")String param
            ,@RequestParam("mainCabCode") String mainCabCode
            ,String tab
    ){
        return materielReportService.queryStoreSkuOrCabRanking(endTime,selectParam,param,mainCabCode,JwtUtils.getEnterpriseCode(),"cab",tab);
    }

    @ApiOperation(value = "存刀柜物料在库排名(按存入人)", notes = "搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "param", value = "开关参数(数量-qua 金额-money)",  dataType = "String", paramType = "query")
    })
    @GetMapping("/queryStoreCreatorRanking")
    public JsonResult queryStoreCreatorRanking(
            @RequestParam("endTime")String endTime
            ,@RequestParam("param")String param
            ,@RequestParam("mainCabCode") String mainCabCode
    ){
        return materielReportService.queryStoreCreatorRanking(endTime,param,mainCabCode,JwtUtils.getEnterpriseCode());
    }
}
